package com.evil.kingdom.service.alliance.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.evil.kingdom.pojo.entity.alliance.Alliance;
import com.evil.kingdom.pojo.entity.base.Belong;
import com.evil.kingdom.repository.alliance.AllianceRepository;
import com.evil.common.mongo.service.impl.SingleServiceImpl;
import com.evil.kingdom.service.alliance.AllianceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 结盟
 *
 * @author liyang
 * @date 2024-05-22 17:46
 */
@Slf4j
@Service
public class AllianceServiceImpl extends SingleServiceImpl<AllianceRepository, Alliance> implements AllianceService {

    @Override
    public boolean isAlliance(Belong a, Belong b) {
        return CollectionUtil.isNotEmpty(this.repository.existsAllianceByBelongs(ListUtil.toList(a.getBelong(), b.getBelong())));
    }
}
